Skip to content

pebble-release-2.1: rowblk: fix IsLowerBound to account for synthetic suffix#6082

Merged
RaduBerinde merged 1 commit into
cockroachdb:pebble-release-2.1from
RaduBerinde:rowblk-lower-bound-fix-pebble-2.1
May 27, 2026
Merged

pebble-release-2.1: rowblk: fix IsLowerBound to account for synthetic suffix#6082
RaduBerinde merged 1 commit into
cockroachdb:pebble-release-2.1from
RaduBerinde:rowblk-lower-bound-fix-pebble-2.1

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

Iter.firstUserKey has the synthetic prefix prepended but the on-disk suffix is preserved; suffix replacement is only applied per-returned key via maybeReplaceSuffix. Comparing firstUserKey directly against the probe could return true even though the iterator's actual first key (after synthetic suffix replacement) sorts strictly less than the probe, violating the blockiter.Data.IsLowerBound contract.

When a synthetic suffix is in effect, only compare the prefix portion of firstUserKey and require it to be strictly greater than the probe. The contract permits false negatives, so this conservative comparison is sound and avoids reasoning about the unknown suffix.

Adds TestIsLowerBoundRandomized which cross-checks IsLowerBound against First() across random blocks and transform combinations, and documents the transform state of firstUserKey.

@RaduBerinde RaduBerinde requested a review from sumeerbhola May 26, 2026 23:03
@RaduBerinde RaduBerinde requested a review from a team as a code owner May 26, 2026 23:03
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

`Iter.firstUserKey` has the synthetic prefix prepended but the on-disk
suffix is preserved; suffix replacement is only applied per-returned key
via `maybeReplaceSuffix`. Comparing `firstUserKey` directly against the
probe could return true even though the iterator's actual first key
(after synthetic suffix replacement) sorts strictly less than the probe,
violating the `blockiter.Data.IsLowerBound` contract.

When a synthetic suffix is in effect, only compare the prefix portion of
`firstUserKey` and require it to be strictly greater than the probe. The
contract permits false negatives, so this conservative comparison is
sound and avoids reasoning about the unknown suffix.

Adds `TestIsLowerBoundRandomized` which cross-checks `IsLowerBound`
against `First()` across random blocks and transform combinations, and
documents the transform state of `firstUserKey`.
@RaduBerinde RaduBerinde force-pushed the rowblk-lower-bound-fix-pebble-2.1 branch from d9be034 to c6860d3 Compare May 27, 2026 17:18
@RaduBerinde RaduBerinde merged commit dbdc1ac into cockroachdb:pebble-release-2.1 May 27, 2026
7 checks passed
@RaduBerinde RaduBerinde deleted the rowblk-lower-bound-fix-pebble-2.1 branch May 27, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants